<%@ page language="java" %>

<%@ page import="java.util.*,
                 java.net.*,
                 java.lang.*,
                 com.broadvision.web.util.ViewDynaBean,
		 org.apache.struts.validator.DynaValidatorForm,
                 org.apache.commons.beanutils.PropertyUtils"
%>

<%@ taglib uri="/WEB-INF/bv-html.tld" prefix="bvhtml" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 

<script language="javascript">
  
function doDocTypeNewAction(theForm) {
  theForm.action = '<html:rewrite page="/cm/docTypeCreate.do"/>';
  theForm.submit();
  return true;
}

function doDocTypeEditAction(theForm, value) {
  theForm.name.value = value;
  theForm.action = '<html:rewrite page="/cm/docTypeEdit.do?dtAction=edit"/>';
  theForm.submit();
  return true;
}
  
function trimAndSubmit(theForm) {
  var tmp = theForm.sName.value;
  theForm.sName.value = tmp.stringTrim();
  theForm.submit();
  return true;
}
</script>

<% String ctxPath = request.getContextPath(); %>

<jsp:useBean id="cmDocTypeListView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 
<bean:size id="resultSize" name="cmDocTypeListView" property="docTypeList"/>

<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle='cm.messages' key='cm.content.docType.list'/>">
  <tr> 
  <td valign="top" width="100%">
		  
  <div class="pageTitle">
    <bean:message bundle='cm.messages' key='cm.content.docType.list'/>
  </div>
  
  <html:form action="/cm/docTypeSearch.do?action=search">
  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="2" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.docTypeSearch.criteria'/>">
    <tr> 
    <td width="10%" nowrap><b><bean:message bundle='cm.messages' key='cm.content.docType.label'/>:</b></td>
    <td width="30%" nowrap>
      <html:text property="sName" size="31" maxlength="80" />
    </td>
    
    <td width="60%" nowrap>
      <input hspace="40" type="submit" name="btn_action" class="inputButton"  onclick="javascript:trimAndSubmit(document.cmContentDocTypeSearchPopupForm);" value="<bean:message bundle='cm.messages' key='button.goto'/>">
    </td>
    </tr>
  </table>
  </html:form>
  
  <logic:match name="cmDocTypeListView" property="searchResultMsg" value="ShowResults">
  <div class="pageSubtitle">
    <span class="left"><bean:message bundle='cm.messages' key='cm.content.docType.list'/></span>
    <span class="right">
            <html:button styleClass="titleButton" property="submitBtn" onclick="return doDocTypeNewAction(document.cmContentDocTypeEditForm);">
              <bean:message bundle='cm.messages' key="button.newDocType"/>
            </html:button>
    </span>
  </div> 
  
  <html:form action="/cm/docTypeEdit.do?action=edit">
  <input type="hidden" name="name"/>

  <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle='cm.messages' key='cm.content.docType.list'/>">
  <tr class="listHeader"> 
    <th id="Name" align="left"><bean:message bundle='cm.messages' key='cm.content.docType.name'/></th>
    <th id="Friendly Name" align="left"><bean:message bundle='cm.messages' key='cm.content.docType.fname'/></th>
    <th id="Actions" align="left" nowrap><bean:message bundle='cm.messages' key='cm.content.docType.actions'/></th>
  </tr>     
  
  <logic:equal name="resultSize" value="0">
  <tr class="listEven"> 
    <td colspan="3" valign="top" align="center"><bean:message bundle='cm.messages' key='cm.content.docType.noDocTypeFound'/></td>
  </tr>
  </logic:equal>

  <logic:iterate id="docType" name="cmDocTypeListView" property="docTypeList" indexId="index">  
    <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
      <td headers="Name"><bean:write name="docType" property="name"/></td>
      <td headers="Friendly Name"><bean:write name="docType" property="friendlyName"/></td>
      <td headers="Actions">
        <a href="#" onclick='javascript:doDocTypeEditAction(document.cmContentDocTypeEditForm, "<bean:write name='docType' property='name'/>")'>
        <img src="<%=ctxPath%>/mc/images/action/icon_edit.gif" width="15" height="15" border="0" class="actionIcon" alt='<bean:message bundle='cm.messages' key='image.alt.editDocType'/>' title='<bean:message bundle='cm.messages' key='image.alt.editDocType'/>' />
        </a>
      </td>
    </tr>
  </logic:iterate>
  
  </table>
  </html:form>
  </logic:match>
  
  </td>
  </tr>
</table>
